import 'package:flutter/material.dart';
import 'package:xinxuan/common/appbar_util.dart';
import 'package:xinxuan/common/button_util.dart';
import 'package:xinxuan/common/network_image_util.dart';
import 'package:xinxuan/common/scroll_configuration_common.dart';
import 'package:xinxuan/controllers/blind_box/blind_box_prize_page_controller.dart';
import 'package:xinxuan/router/app_routers.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class BlindBoxPrizePage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: pageBgColor,
      appBar: AppBarUtil(
        title: '恭喜中奖',
        backgroundColor: pageBgColor,
      ),
      body: GetBuilder<BlindBoxPrizePageController>(
        init: BlindBoxPrizePageController(),
        builder: (controller) {
          if (controller.blindBoxOrderDetailData.value.id == 0) {
            return Container();
          }
          return ScrollConfigurationCommon(child: ListView(
            children: [
              Stack(
                children: [
                  NetworkImageUtil(
                    url: controller.blindBoxOrderDetailData.value.lottery!.product!.image ?? '', 
                    width: 375.w, 
                    height: 492.h
                  ),
                  Positioned(
                    top: 76.h,
                    child: controller.blindBoxOrderDetailData.value.lottery!.product!.type == 2 ? Container(
                      padding: EdgeInsets.symmetric(horizontal: 14.w),
                      child: Text(
                        '获得:${controller.blindBoxOrderDetailData.value.lottery!.product!.title}',
                        style: TextStyle(
                          color: textWhiteColor,
                          fontSize: 34.sp,
                          shadows: <Shadow>[
                            Shadow(
                              offset: Offset(0, 3.h),
                              blurRadius: 6.h,
                              color: mainTextColor,
                            )
                          ],
                        ),
                      ),
                    ) : Container()
                  )
                ],
              ),
              Container(
                padding: EdgeInsets.symmetric(horizontal: 24.w),
                margin: EdgeInsets.only(top: 18.h),
                child: ButtonUtil(
                  text: '查看奖品', 
                  fontSize: 16.sp, 
                  borderRadius: 36.h, 
                  height: 36.h, 
                  onTop: () {
                    if (controller.blindBoxOrderDetailData.value.lottery!.product!.type == 2) {
                      Get.offNamed('${AppRouters.COMMON_PAGE}${AppRouters.GRATITUDE_RECORD_PAGE}');
                      return;
                    }
                    Get.offNamed(
                      '${AppRouters.COMMON_PAGE}${AppRouters.BLINDBOX_ORDER_PAGE}${AppRouters.BLINDBOX_ORDER_DETAIL_SUCCESS_PAGE}',
                      arguments: {
                        'id': controller.blindBoxOrderDetailData.value.id!,
                        'title': controller.blindBoxOrderDetailData.value.statusStr
                      }
                    );
                  }
                ),
              )
            ],
          ));
        },
      ),
    );
  }
}